import React, { Component } from 'react';
import { Table} from 'antd';
export default class index extends Component {
    state={
        dataSource : [
            {
              key: '1',
              name: '胡彦斌',
              age: 32,
              address: '西湖区湖底公园1号',
            },
            {
              key: '2',
              name: '胡彦祖',
              age: 42,
              address: '西湖区湖底公园1号',
            },
        ],
        dataSourceList:[]
    }
    getTableList=async ()=>{
        let {myId,sel} = this.props
        let result = await this.api.get('categories/'+myId+'/attributes/?sel='+sel)
        if(result.meta.status === 200){
            this.setState({
                dataSourceList:result.data
            })
        }
        console.log(result);
       
    }
    componentDidMount(){
        this.getTableList()
    }
    render(){
       let {dataSource,dataSourceList} = this.state
       
          const columns = [
            {
              title: 'id',
              dataIndex: 'id',
              key: 'id',
            },
            {
              title: '分类',
              dataIndex: 'age',
              key: 'age',
            },
            {
              title: '操作',
              dataIndex: 'address',
              key: 'address',
            },
          ];
          const columnslist = [
            {
              title: 'id',
              dataIndex: 'id',
              key: 'id',
            },
            {
              title: '分类',
              dataIndex: 'age',
              key: 'age',
            },
            {
              title: '操作',
              dataIndex: 'address',
              key: 'address',
            },
          ];
         return (
             <div>
                 <Table dataSource={dataSource} columns={columns} />;
                 <Table dataSource={dataSourceList} columns={columnslist} />;
             </div>
        )
    }
}
